//package com.lzx.adx.report.task;
//
//import cn.hutool.core.collection.CollectionUtil;
//import com.alibaba.fastjson.JSON;
//import com.google.common.collect.Lists;
//import com.lzx.adx.report.dto.TbCpaListDTO;
//import com.lzx.adx.report.service.TbCpaListService;
//import com.lzx.adx.report.util.DateFormatUtils;
//import com.taobao.api.DefaultTaobaoClient;
//import com.taobao.api.TaobaoClient;
//import com.taobao.api.request.TbkDgVegasSendReportRequest;
//import com.taobao.api.response.TbkDgVegasSendReportResponse;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import java.util.Objects;
//
//@Component
//@RestController
//@RequestMapping("/tb/task")
//@Slf4j
//public class TbUnionCpaListTask implements ITask{
//    //地址
//    public static final String url="http://gw.api.taobao.com/router/rest";
//    public static final String appKey="34680642";
//    public static final String appSecret="596c7ba138eb08b33167690bdcb2555b";
//
//    @Resource
//    private TbCpaListService tbCpaListService;
//
//
//    /**
//     * 查询红包类型，1-超级红包，2-福利购，3-签到红包，4-福利直降，5-幸运赢免单，不传时默认查询超级红包数据
//     * @param params   参数，多参数使用JSON数据
//     * @throws Exception
//     */
//    @RequestMapping("/cpa")
//    @Override
//    public void run(String params) throws Exception {
//
//        String todayDate = DateFormatUtils.getTodayDate();
//        getList(todayDate, 1L);
//        getList(todayDate, 2L);
//        getList(todayDate, 3L);
//        getList(todayDate, 4L);
//        getList(todayDate, 5L);
//    }
//
//
//    public  List<TbCpaListDTO>  getList(String date,Long type){
//       try {
//           TaobaoClient client = new DefaultTaobaoClient(url, appKey, appSecret);
//           TbkDgVegasSendReportRequest req = new TbkDgVegasSendReportRequest();
//           req.setBizDate(date);
//           req.setPageNo(1L);
//           req.setPageSize(5000L);
//           req.setActivityCategory(type);
//           TbkDgVegasSendReportResponse rsp = client.execute(req);
//           TbkDgVegasSendReportResponse.Result result = rsp.getResult();
//           if(Objects.isNull(result)){
//               return Lists.newArrayList();
//           }
//           TbkDgVegasSendReportResponse.RightsSendRptDTO model = result.getModel();
//           if(Objects.isNull(model)){
//               return Lists.newArrayList();
//           }
//           List<TbkDgVegasSendReportResponse.RightsSendRelationRptDto> pidRptList = model.getPidRptList();
//           List<TbCpaListDTO> dataList=new ArrayList<>();
//           if(CollectionUtil.isNotEmpty(pidRptList)){
//               for (TbkDgVegasSendReportResponse.RightsSendRelationRptDto rightsSendRelationRptDto : pidRptList) {
//                   TbCpaListDTO tbCpaListDTO=new TbCpaListDTO();
//                    tbCpaListDTO.setPid(rightsSendRelationRptDto.getPid());
//                    tbCpaListDTO.setDay(DateFormatUtils.convertDateToStr(date));
//                    tbCpaListDTO.setType(String.valueOf(type));
//                    tbCpaListDTO.setGrantNum(rightsSendRelationRptDto.getFundNum());
//                    tbCpaListDTO.setUseNum(rightsSendRelationRptDto.getUseNum());
//                    tbCpaListDTO.setCreateTime(new Date());
//                    tbCpaListDTO.setUpdateTime(new Date());
//                    tbCpaListDTO.setAppkey(appKey);
//                     tbCpaListService.handTbCappData(tbCpaListDTO);
//               }
//               return dataList;
//           }
//
//       }catch (Exception e){
//         log.error("解析结果出现了异常，异常的参数为{}",e);
//       }
//       return Lists.newArrayList();
//    }
//
//
//
//
//
//}
